import LayoutVertical from "@/layouts/index";
import { Loading } from "@/components/Loading";
import { HOME_URL, LOGIN_URL } from "@/config";
import ErrorComponents from "@/components/Error";
import RouterGuard from "../helper/RouterGuard";
import Login from "@/pages/login/index.jsx";
import { mainRoutes } from "@/router/main.jsx";
import { HomeOutlined, SearchOutlined, SettingOutlined } from "@ant-design/icons";

const { NotAuth, NotFound, NotNetwork, ErrorPage } = ErrorComponents;
export const staticRouter: any[] = [
  {
    path: "/",
    element: <LayoutVertical />,
    meta: {
      title: "首页",
      icon: <HomeOutlined />
    },
    children: mainRoutes
  },
  {
    path: "/login",
    element: <Login />,
    meta: { title: "登录" }
  },
  {
    path: "/403",
    element: <NotAuth />,
    meta: {
      title: "403"
    }
  },
  {
    path: "/404",
    element: <NotFound />,
    meta: {
      title: "404"
    }
  },
  {
    path: "/500",
    element: <NotNetwork />,
    meta: {
      title: "500"
    }
  },
  {
    path: "*",
    element: <Loading />
  }
];

export const wrappedStaticRouter = staticRouter.map(route => {
  return {
    ...route,
    element: <RouterGuard>{route.element}</RouterGuard>,
    loader: () => {
      return { ...route.meta };
    }
  };
});
